package com.standard.logcat.entity

import androidx.annotation.ColorRes
import com.standard.logcat.R
import com.standard.logcat.jsonFormatter.JsonFormatter

data class LogcatItem(var log: String, @ColorRes var color: Int = R.color.logcat_white) {
    init {
        if (log.contains("-->") || log.contains("<--")) {
            color = if (log.contains("END")) {
                R.color.logcat_orange
            } else {
                R.color.logcat_blue
            }
        }

        if ((log.startsWith("{") && log.endsWith("}")) ||
            (log.startsWith("[") && log.endsWith("]"))
        ) {
            log = JsonFormatter.formatter(log)
        }
    }
}
